package com.springboot.myspringbootframework.domain.user.utils;

import com.springboot.myspringbootframework.domain.user.api.dto.UserDTO;
import com.springboot.myspringbootframework.domain.user.entities.User;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.stream.Collectors;

public class Convertors {

    public  static UserDTO User2UserDTO(User user){
        UserDTO userDTO = new UserDTO();
        BeanUtils.copyProperties(user,userDTO);
        return userDTO;
    }

    public static List<UserDTO> Users2UserDTOs(List<User> list) {
        return list.stream().map(t-> User2UserDTO(t)).collect(Collectors.toList());
    }
}
